home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
ndp.zip
/
NDP_TYPE.DOC
< prev
next >
Wrap
Text File
|
1987-08-02
|
6KB
|
138 lines
/*
NDP_TYPE.DOC
NOTE: All of the Coprocessor logic, detection and typing, in the
enclosed files are the copyrighted work of Ted Forgeron as presented
in his article in PC Tech Journal, Aug 87, p 43. The limit of my
contribution to this effort is in the development of the C language
interface and the examples. Pat Shea/Psi! 080187
This archive should contain six [6] files, as follows:
(1) NDP_TYPE.ASM -- the source code to produce a linkable object
file [for use with Microsoft C] containing ndp_type(), a
function which reports the presence and type of NDP in a
system at runtime. Since there are no data passed to this
function when called, and only 1 byte coming back to the
caller, I have elected to pass this byte in AL as the func-
tion's return code. With very minor modification, this code
can be used to produce a linkable object for other languages
such as Fortran or PASCAL, or it can be incorporated into
other ASM programs.
(2) NDP_TYPE.DOC -- this file that you are now reading. In addi-
tion to being the documentation for this archive, it is a
compilable C language program [see TEST_IT.EXE below].
(3) NDP_TYPE.OBJ -- what you get when you assemble NDP_TYPE.ASM.
It contains ndp_type(), the function that does all of the
work described below in the TEST_NDP.ASM description and is
callable from MSC. Presently, this function is set for the
Small Memory model.
Calling: int ndp_type( void );
Returns: 0 if NO CHIP is found
1 if an 8087 is found
2 if an 80287
and 3 for an 80387
(4) TEST_IT.EXE -- what you get when you compile/link this docu-
ment as follows:
MSC ndp_type.doc, test_it; [NOTE: name change !!]
LINK test_it + ndp_type;
The file that you end up with, TEST_IT.EXE does exactly the
same thing that TEST_NDP.COM does but is C language based
and calls the assembler function, ndp_type() contained in
the enclosed OBJ file to do all of the work for it. A quick
review of the C source code below will show that the only
things that I am doing in C are interpreting the results
from ndp_type(), some string handling and putting data on
the screen.
(5) TEST_NDP.ASM -- source code for an executable program which
detects the presence of an NDP [Numeric Data Processor or
Math Coprocessor] in an Intel 8086 based computer running
under DOS [version independent]. Additionally, it reports
the type of NDP present - 8087, 80287 or 80387.
(6) TEST_NDP.COM -- the executable program produced from the
above source code via MASM /R --> LINK --> EXE2BIN.
COMMENTS:
The function, ndp_type(), has been tested on an IBM XT mod 089
containing and Intel 8087, an IBM AT mod 339 with an Intel 80287
and a COMPAQ 386 with no Coprocessor. It seems to do its thing
correctly. Unfortunately, I do not have access to a machine with
an 80387 as yet so that part of the logic must remain untested
for the time.
These files are the product of a nocturnal hack brought on by
reading some interesting code in PCTJ. Feel free to comment,
ridicule, modify, improve, use or discard as you see fit. Howev-
er, if changes to the function, ndp_type() are distributed, please
carry forward Ted Forgeron's copyright information on the
coprocessor logic.
enjoy!!
Pat Shea, AJ3B /Psi!
[76210,712]
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int ndp_type( void ); /* This is the function that duz the work.
Everything else is standard library stuff
and is declared in the #include's. */
main()
{
int numb;
char str[26];
putchar( '\n' );
puts( "Checking for a Math Coprocessor...." );
putchar( '\n' );
strcpy( str, "I see " );
numb = ndp_type(); /* This is where we pick up the return
value so that we can determine the
type of NDP present, if any.
NOTE: If Ur not interested in the specific type NDP that is
present and only want to find out if one is available,
just test for a nonzero return value from ndp_type().
However, if your return value is >3, something is VERY
wrong !! */
switch ( numb )
{
case 0:
strcat( str, "NO CHIP " );
break;
case 1:
strcat( str, "an 8087 " );
break;
case 2:
strcat( str, "an 80287 " );
break;
case 3:
strcat( str, "an 80387 " );
break;
default:
puts( "Abandon Ship!" );
exit( 0 );
}
strcat( str, "in here !!" );
puts( str );
putchar( '\n' );
return( 0 );
} /* */